package pers.cz.service.impl;

import pers.cz.business.TestConfigBusiness;
import pers.cz.model.HostsAddress;
import pers.cz.pub.BeanHelper;
import pers.cz.service.TestConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @program: PostGirl-panent
 * @description: TestConfigServiceImpl
 * @author: Cheng Zhi
 * @create: 2021-08-20 15:33
 **/
@Service
public class TestConfigServiceImpl implements TestConfigService {

    @Autowired
    BeanHelper beanHelper;

    @Override
    public List<HostsAddress> getAllHostsAddress() {

        TestConfigBusiness business = new TestConfigBusiness();
        business.setMapper(beanHelper);

        return business.getAllHostsAddress();
    }

    @Override
    public List<HostsAddress> getAllHostsAddresByPage(Integer pageStart, Integer pageLimit) {
        TestConfigBusiness business = new TestConfigBusiness();
        business.setMapper(beanHelper);
        return business.queryAllAddressByPage(pageStart, pageLimit);
    }

    @Override
    public Integer updateHostsAddress(HostsAddress hostsAddress) {
        TestConfigBusiness business = new TestConfigBusiness();
        business.setMapper(beanHelper);
        return business.updateAddress(hostsAddress);
    }

    @Override
    public Integer delteHostsAddress(Long id) {

        TestConfigBusiness business = new TestConfigBusiness();
        business.setMapper(beanHelper);
        return business.deleteAddress(id);
    }

    @Override
    public Integer addHostsAddress(HostsAddress hostsAddress) {

        TestConfigBusiness business = new TestConfigBusiness();
        business.setMapper(beanHelper);
        return business.addAdddress(hostsAddress);
    }

    @Override
    public Integer getAddressTotalNum() {
        TestConfigBusiness business = new TestConfigBusiness();
        business.setMapper(beanHelper);
        return business.getAddressTotalNum();
    }

    @Override
    public List<HostsAddress> queryAddress(String enviName, String hostsAddress) {

        TestConfigBusiness business = new TestConfigBusiness();
        business.setMapper(beanHelper);
        return business.queryAddress(enviName, hostsAddress);
    }

}
